package org.jeecg.modules.system.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.poi.ss.formula.functions.T;

import org.jeecg.modules.system.entity.Trxrecord;
import org.jeecg.modules.system.mapper.TrxrecordMapper;
import org.jeecg.modules.system.service.ITrxrecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Description: trxrecord
 * @Author: jeecg-boot
 * @Date:   2021-08-12
 * @Version: V1.0
 */
@Service
public class TrxrecordServiceImpl extends ServiceImpl<TrxrecordMapper, Trxrecord> implements ITrxrecordService {
    @Autowired
    private TrxrecordMapper trxrecordMapper;
    public Trxrecord queryTrxrecordBytrxid(String trxid){
        QueryWrapper queryWrapper=new QueryWrapper<Trxrecord>();
        queryWrapper.select("trxid","paytype","trxamt","paytime","finishamt","backamt","finishtime","trxstatus");
        queryWrapper.eq("trxid",trxid);


        Trxrecord trxrecord=trxrecordMapper.selectOne(queryWrapper);
        return trxrecord;
    }
    public void insertTrxrecord(Trxrecord trxrecord){
        trxrecordMapper.insert(trxrecord);
    }

    public void updateTrxrecord(Trxrecord trxrecord){
        UpdateWrapper<Trxrecord> updateWrapper =new UpdateWrapper<Trxrecord>();
        updateWrapper.set("backamt", trxrecord.getBackamt());
        updateWrapper.set("finishamt", trxrecord.getFinishamt());
        updateWrapper.eq("trxid", trxrecord.getTrxid());
        trxrecordMapper.update(trxrecord,updateWrapper);
        System.out.println("更新数据成功");
    }

    public void FinishupdateTrxrecord(Trxrecord trxrecord){
        UpdateWrapper<Trxrecord> updateWrapper =new UpdateWrapper<Trxrecord>();
        //updateWrapper.set("backamt", trxrecord.getBackamt());
        //updateWrapper.set("finishamt", trxrecord.getFinishamt());
        updateWrapper.set("finishtrxid", trxrecord.getFinishtrxid());
        updateWrapper.set("finishtime", trxrecord.getFinishtime());
        updateWrapper.eq("trxid", trxrecord.getTrxid());
        trxrecordMapper.update(trxrecord,updateWrapper);
        System.out.println("更新数据成功");
    }





}
